package mamma.dao;

import java.util.List;

import mamma.common.MybatisConfig;
import mamma.vo.CalendarVo;
import mamma.vo.InformationVo;
import mamma.vo.SaleBoardVo;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

//import test.SaleBoardVo.SaleBoardVo;

public class jihoonDao {
	private SqlSessionFactory factory;
	
	public jihoonDao(){
		factory = MybatisConfig.getSqlSessionFactory();
	}
	
	
	public List<InformationVo> clist(){		//공지일정 리스트가져오기
		SqlSession ss=null;
		List<InformationVo> infoList=null;
		try {
			ss=factory.openSession();
			infoList=ss.selectList("jihoon.selectinfo");
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		} return infoList;
	}
	
	public List<InformationVo> clist2(){	//고객일정리스트 가져오기
		SqlSession ss=null;
		List<InformationVo> infoList2=null;
		try {
			ss=factory.openSession();
			infoList2=ss.selectList("jihoon.selectinfo2");
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		} return infoList2;
	}
	
	public void scheduleIns(CalendarVo vo){	//스케줄 추가
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.insert("jihoon.insertSchedule",vo);
			ss.commit();
		} catch (Exception e) {
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		}
	}
	
/*	
	public void scheduleDelA(int id){		//운영자글삭제 고객모드에선 운영자글 삭제 ㄴㄴ
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.delete("jihoon.deleteScheduleA",id);
			ss.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally{
			if(ss!=null) ss.close();
		}
	}*/
	
	public void scheduleDelC(int id){		//고객글삭제
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.delete("jihoon.deleteScheduleC",id);
			ss.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally{
			if(ss!=null) ss.close();
		}
	}
	public void scheduleShiftC(CalendarVo vo){ //고객글이동
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.update("jihoon.shiftSchedule", vo);
			ss.commit();
		} catch (Exception e) {
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		}
		
	}
	
	public void scheduleUpd(CalendarVo vo){	//고객글 수정
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.update("jihoon.updateSchedule", vo);
			ss.commit();
		} catch (Exception e) {
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		}
	}
	
	public void scheduleScr(CalendarVo vo){	//고객글 일정이동
		SqlSession ss=null;
		try {
			ss=factory.openSession();
			ss.update("jihoon.scrSchedule", vo);
			ss.commit();
		} catch (Exception e) {
			// TODO: handle exception
		} finally{
			if(ss!=null) ss.close();
		}
	}
	
//장터게시판
	//목록읽기
/*	public List<SaleBoardVo> listSaleBoardVo() {
		SqlSession ss=null;
		List<SaleBoardVo> saleList = null;
		try {
			ss = factory.openSession();
			saleList = ss.selectList("jihoon.listSaleBoardVo");
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		
		return saleList;
	}
	//장터게시판 글등록
	public int WriteReservationSaleBoard(SaleBoardVo saleVo) {
		int check=0;
		SqlSession ss=null;
		try {
			ss = factory.openSession();
			check = ss.insert("SaleBoardVo.WriteReservationSaleBoard",saleVo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		return check;
	}
	//장터게시판 글읽기
	public SaleBoardVo readSaleBoard(SaleBoardVo saleVo1) {
		SqlSession ss=null;
		SaleBoardVo saleVo = null;
		
		try {
			ss = factory.openSession();
			saleVo = ss.selectOne("jihoon.readSaleBoard", saleVo1);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		return saleVo;
	}
	//장터게시판 글수정이동
	public SaleBoardVo GoUpdateFormSaleBoard(SaleBoardVo SaleBoardVo) {
		SaleBoardVo SaleVo = null;
		SqlSession ss=null;
		try {
			ss = factory.openSession();
			SaleVo=ss.selectOne("jihoon.readSaleBoard", SaleBoardVo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		return SaleVo;
	}
	//장터게시판 글수정
	public int UpdateReservationSaleBoard(SaleBoardVo saleVo) {
		int check = 0;
		SqlSession ss=null;
		try {
			ss = factory.openSession();
			ss.update("jihoon.UpdateReservationSaleBoard", saleVo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		return check;
	}
	//장터게시판 글삭제
	public int DeleteSaleBoard(int saleboardNum) {
		int check = 0;
		SqlSession ss=null;
		try {
			ss = factory.openSession();
			check = ss.delete("jihoon.DeleteSaleBoard", saleboardNum);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		return check;
	}*/
	
	//장터게시판
/*	public List<SaleBoardVo> listSaleBoardVo() {
		SqlSession ss=null;
		List<SaleBoardVo> SaleBoardVolist = null;
		try {
			ss = factory.openSession();
			SaleBoardVolist = ss.selectList("jihoon.listSaleBoardVo");
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		
		return SaleBoardVolist;
	}
	
	public int writeSaleBoardVo(SaleBoardVo SaleBoardVo) {
		int check = 0;
		SqlSession ss=null;
		try {
			ss = factory.openSession();
			check = ss.insert("jihoon.writeSaleBoardVo", SaleBoardVo);
			ss.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(ss != null) ss.close();
		}
		
		return check;
	}







*/
	
	
}
